//
//  DeclineViewController.m
//  Tour
//
//  Created by dllo on 15/10/22.
//  Copyright (c) 2015年 蓝鸥科技. All rights reserved.
//

#import "DeclineViewController.h"
#import "AdvanceEdit.h"
#import "ScrollWebViewController.h"
#import "ZGSDownTableViewCell.h"
#import "ZGSmoreSpecialViewController.h"
#define WIDTH self.view.frame.size.width
#import "ZGSSearchViewController.h"
#import <MJRefresh.h>
@interface DeclineViewController ()<UIScrollViewDelegate, UITableViewDataSource, UITableViewDelegate>
//@property (nonatomic, retain)UITableView
@property (nonatomic, retain)UIView *headView;
@property (nonatomic, retain)UIScrollView *upScroll;
@property (nonatomic, retain)UITableView *tableView;
@property (nonatomic, retain)NSMutableArray *scrollArr;
@property (nonatomic, retain)UIImageView *scrollImage;
@property (nonatomic, retain)UIImageView *firstImage;
@property (nonatomic, retain)UIImageView *lastImage;
@property (nonatomic, retain)NSMutableArray *arrImage;
@property (nonatomic, retain)UIImageView *buttonFirst;
@property (nonatomic, retain)UIImageView *buttonSecond;
@property (nonatomic, retain)UIImageView *buttonThird;
@property (nonatomic, retain)NSMutableArray *downArr;
@property (nonatomic, assign)NSInteger page;
@property (nonatomic, retain)MBProgressHUD *HUD;
@property (nonatomic, retain)NSMutableArray *arr;
@property (nonatomic, retain)NSMutableArray *arrImages;
@end



@implementation DeclineViewController

- (void)viewDidLoad {
    
//    self.collectionview.header = [mjre]
    [super viewDidLoad];
    self.navigationController.navigationBar.translucent = NO;
    self.navigationController.navigationBarHidden = NO;
    self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemSearch target:self action:@selector(searchbarAction:)];
    self.title = @"首页";
    // Do any additional setup after loading the view.

    self.navigationController.hidesBarsOnSwipe = YES;
    self.tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, WIDTH, self.view.frame.size.height - 104) style:UITableViewStylePlain];
    self.tableView.dataSource = self;
    self.tableView.delegate = self;
    [self.tableView registerClass:[ZGSDownTableViewCell class] forCellReuseIdentifier:@"reusetable"];
    self.tableView.rowHeight = 90;
    [self.view addSubview:self.tableView];
    
    
    self.headView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, WIDTH, 733)];
    self.tableView.tableHeaderView = self.headView;
    
    self.view.backgroundColor = [UIColor whiteColor];
//    self.upScroll = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, 350)];
//    self.upScroll.contentSize = CGSizeMake((self.scrollArr.count + 2) * WIDTH, 0);
//    [self.headView addSubview:self.upScroll];
    UILabel *diccover = [[UILabel alloc] initWithFrame:CGRectMake(10, 350, WIDTH, 25)];
    diccover.text = @"发现下一站";
    diccover.font = [UIFont systemFontOfSize:13];
    diccover.textColor = [UIColor grayColor];
    [self.headView addSubview:diccover];
   //    self.scrollImage = [UIImageView alloc] initWithImage:<#(UIImage *)#>
    

    
    self.buttonFirst = [[UIImageView alloc] init];
    self.buttonFirst.frame = CGRectMake(5, 375, WIDTH - 10, 150);
    
    self.buttonSecond = [[UIImageView alloc] init];
    self.buttonSecond.frame = CGRectMake(5, 530, (WIDTH - 10) / 2, 150);

    self.buttonThird = [[UIImageView alloc] init];
    self.buttonThird.frame = CGRectMake(10 + (WIDTH - 10) / 2, 530, (WIDTH - 10) / 2 - 5, 150);
    
    self.buttonFirst.userInteractionEnabled = YES;
    self.buttonSecond.userInteractionEnabled = YES;
    self.buttonThird.userInteractionEnabled = YES;

    //点击方法
    UITapGestureRecognizer *tapfirst = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(tapFirstAction:)];
    [self.buttonFirst addGestureRecognizer:tapfirst];
    tapfirst.numberOfTapsRequired = 1;
    tapfirst.numberOfTouchesRequired = 1;
    [tapfirst release];
    
    UITapGestureRecognizer *tapsecond = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(tapSecondAction:)];
    [self.buttonSecond addGestureRecognizer:tapsecond];
    tapsecond.numberOfTapsRequired = 1;
    tapsecond.numberOfTouchesRequired = 1;
    [tapsecond release];
    
    UITapGestureRecognizer *tapThird = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(tapThirdAction:)];
    [self.buttonThird addGestureRecognizer:tapThird];
    tapThird.numberOfTapsRequired = 1;
    tapThird.numberOfTouchesRequired = 1;
    [tapThird release];
   
    //
    UIButton *moreSpecial = [UIButton buttonWithType:UIButtonTypeSystem];
    moreSpecial.frame = CGRectMake(0, 683, WIDTH, 50);
    [moreSpecial setTitle:@"查看更多专题" forState:UIControlStateNormal];
    [self.headView addSubview:moreSpecial];
    [moreSpecial addTarget:self action:@selector(moreSpecialAction:) forControlEvents:UIControlEventTouchUpInside];
    
    self.HUD = [MBProgressHUD showHUDAddedTo:self.view animated:YES];
    self.HUD.labelText = @"正在加载";
    self.HUD.dimBackground = YES;
//
    [self iswlan];

        [self creatData];
      [NSTimer scheduledTimerWithTimeInterval:3 target:self selector:@selector(AutoRollAction) userInfo:nil repeats:YES];
    
    
    //下拉
    self.tableView.header = [MJRefreshNormalHeader headerWithRefreshingTarget:self refreshingAction:@selector(header)];
    //上啦
    self.tableView.footer = [MJRefreshAutoNormalFooter footerWithRefreshingTarget:self refreshingAction:@selector(footer)];}

- (void)AutoRollAction{
    if (self.upScroll.contentOffset.x >= WIDTH * (self.scrollArr.count + 1)) {
        self.upScroll.contentOffset = CGPointMake(WIDTH, 0);
        return;
    }
    [self.upScroll setContentOffset:CGPointMake(self.upScroll.contentOffset.x + WIDTH, 0) animated:YES];
}

- (void)iswlan {
    AFNetworkReachabilityManager *manager = [AFNetworkReachabilityManager sharedManager];
    [manager startMonitoring];
    [manager setReachabilityStatusChangeBlock:^(AFNetworkReachabilityStatus status) {
        if (status == 1) {
            UIAlertController *aleryController = [UIAlertController alertControllerWithTitle:@"已连接" message:@"为2g/3g网" preferredStyle:UIAlertControllerStyleAlert];
            [self presentViewController:aleryController animated:YES completion:nil];
            UIAlertAction *leftAction = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleCancel handler:nil];
            
            [aleryController addAction:leftAction];
            
        }
        else if (status == 2) {
            UIAlertController *aleryController = [UIAlertController alertControllerWithTitle:@"已连接" message:@"为wifi连接" preferredStyle:UIAlertControllerStyleAlert];
            [self presentViewController:aleryController animated:YES completion:nil];
            UIAlertAction *leftAction = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleCancel handler:nil];
            [aleryController addAction:leftAction];
        }
        else if (status == 0) {
            UIAlertController *aleryController = [UIAlertController alertControllerWithTitle:@"无连接" message:@"没有连接" preferredStyle:UIAlertControllerStyleAlert];
            [self presentViewController:aleryController animated:YES completion:nil];
            UIAlertAction *leftAction = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleCancel handler:nil];
            [aleryController addAction:leftAction];
            self.HUD.hidden = YES;
//            NSMutableArray *arr = [DeclineUp baseModelArr:dic[@"data"][@"slide"]];
            
            NSString *sandBoxPath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject];
            NSString *docPath = [sandBoxPath stringByAppendingPathComponent:@"zgsa.plist"];
 
            NSArray *temp = [NSKeyedUnarchiver unarchiveObjectWithFile:docPath];
            NSLog(@"%@", temp);
            self.scrollArr = [NSMutableArray array];
            for (DeclineUp *up in temp) {
                [self.scrollArr addObject:up];
            }
            self.upScroll = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, 350)];
            self.upScroll.contentSize = CGSizeMake((self.scrollArr.count + 2) * WIDTH, 0);
            self.upScroll.pagingEnabled = YES;
            self.upScroll.showsHorizontalScrollIndicator = NO;
            self.upScroll.bounces = NO;
            self.upScroll.delegate = self;
            self.upScroll.contentOffset = CGPointMake(WIDTH, 0);
            self.scrollImage.userInteractionEnabled = YES;
            [self.headView addSubview:self.upScroll];
            self.firstImage = [[UIImageView alloc] init];
            self.firstImage.frame = CGRectMake(0, 0, WIDTH, 350);
            [self.firstImage sd_setImageWithURL:[NSURL URLWithString:[self.scrollArr[self.scrollArr.count - 1] photo]]placeholderImage:[UIImage imageNamed:@"10.jpeg"]];
            self.firstImage.userInteractionEnabled = YES;
            [self.upScroll addSubview:self.firstImage];
            self.lastImage = [[UIImageView alloc] init];
            self.lastImage.frame = CGRectMake((self.scrollArr.count + 1) * WIDTH, 0, WIDTH, 350);
            [self.lastImage sd_setImageWithURL:[NSURL URLWithString:[self.scrollArr[0] photo]]placeholderImage:[UIImage imageNamed:@"10.jpeg"]];
            self.lastImage.userInteractionEnabled = YES;
            [self.upScroll addSubview:self.lastImage];
            for (NSUInteger i = 0; i < self.scrollArr.count; i++) {
                self.scrollImage = [[UIImageView alloc] init];
                self.scrollImage.frame = CGRectMake(WIDTH * (i + 1), 0, WIDTH, 350);
                
                [self.upScroll addSubview:self.scrollImage];
                [self.scrollImage sd_setImageWithURL:[NSURL URLWithString:[self.scrollArr[i] photo]]];
                
                //            NSLog(@"%@", [self.scrollArr[i] photo]);
                
            }
            self.arrImage = [NSMutableArray array];
            for (DeclineUp *up in temp) {
                [self.arrImage addObject:up];
            }
            
            
            [self.buttonFirst sd_setImageWithURL:[NSURL URLWithString:[self.arrImage[0] photo]]placeholderImage:[UIImage imageNamed:@"10.jpeg"]];
            [self.headView addSubview:self.buttonFirst];
            
            [self.buttonSecond sd_setImageWithURL:[NSURL URLWithString:[self.arrImage[1] photo]]placeholderImage:[UIImage imageNamed:@"10.jpeg"]];
            [self.headView addSubview:self.buttonSecond];
            
            [self.buttonThird sd_setImageWithURL:[NSURL URLWithString:[self.arrImage[2] photo]]placeholderImage:[UIImage imageNamed:@"10.jpeg"]];
            [self.headView addSubview:self.buttonThird];
            
            
//            NSString *sandBoxPath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject];
//            NSString *docPath = [sandBoxPath stringByAppendingPathComponent:@"zgsatable.plist"];
            NSString *sandBoxPatha = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject];
            NSString *docPatha = [sandBoxPatha stringByAppendingPathComponent:@"zgsatable.plist"];
            NSArray *tempa = [NSKeyedUnarchiver unarchiveObjectWithFile:docPatha];
             NSLog(@"%@!!!!!!!!!!!", tempa);
            self.downArr = [NSMutableArray array];
            for (DeclineUp *down in tempa) {
                [self.downArr addObject:down];
                
            }
            
//            [self.tableView reloadData];


            
            




        }
    }];
}


- (void)creatData{
    AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
    [manager GET:@"http://open.qyer.com/qyer/recommands/entry?client_id=qyer_ios&client_secret=cd254439208ab658ddf9&count=20&lat=38.88227728187325&lon=121.5401304736493&page=1&track_app_channel=App%2520Store&track_app_version=6.7&track_device_info=iPhone7%2C1&track_deviceid=CD8DD9AA-C227-45CD-A07E-DA485B537E39&track_os=ios%25208.4.1&v=1" parameters:nil success:^(AFHTTPRequestOperation *operation, id responseObject) {
        NSDictionary *dic = responseObject;
        //轮播图数据解析
        self.arr = [NSMutableArray array];
        self.arr = [DeclineUp baseModelArr:dic[@"data"][@"slide"]];
        
        
        NSString *sandBoxPath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject];
        NSString *docPath = [sandBoxPath stringByAppendingPathComponent:@"zgsa.plist"];
        //归档
         [NSKeyedArchiver archiveRootObject:self.arr toFile:docPath];

//               NSLog(@"%@", ooo);
//         Student *tempStu = [NSKeyedUnarchiver unarchiveObjectWithFile:docPath];
        //轮播图下面图的数据解析
        self.arrImages = [NSMutableArray array];
        self.arrImages = [DeclineUp baseModelArr:dic[@"data"][@"subject"]];
        
        
        //对轮播图进行赋值操作
        self.scrollArr = [NSMutableArray array];
        for (DeclineUp *up in self.arr) {
            [self.scrollArr addObject:up];
        }
        self.upScroll = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, 350)];
        self.upScroll.contentSize = CGSizeMake((self.scrollArr.count + 2) * WIDTH, 0);
        self.upScroll.pagingEnabled = YES;
        self.upScroll.showsHorizontalScrollIndicator = NO;
        self.upScroll.bounces = NO;
        self.upScroll.delegate = self;
        self.upScroll.contentOffset = CGPointMake(WIDTH, 0);
        self.scrollImage.userInteractionEnabled = YES;
        UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(tapAction:)];
        [self.upScroll addGestureRecognizer:tap];
        //把手势加到指定的试图上
        
        // 点几下才能触发方法
//        tap.numberOfTapsRequired = 1;
//        // 几个手指触摸
//        tap.numberOfTouchesRequired = 1;
        [tap release];
        
        [self.headView addSubview:self.upScroll];
        self.firstImage = [[UIImageView alloc] init];
        self.firstImage.frame = CGRectMake(0, 0, WIDTH, 350);
        [self.firstImage sd_setImageWithURL:[NSURL URLWithString:[self.scrollArr[self.scrollArr.count - 1] photo]]placeholderImage:[UIImage imageNamed:@"10.jpeg"]];
        self.firstImage.userInteractionEnabled = YES;
        [self.upScroll addSubview:self.firstImage];
        self.lastImage = [[UIImageView alloc] init];
        self.lastImage.frame = CGRectMake((self.scrollArr.count + 1) * WIDTH, 0, WIDTH, 350);
        [self.lastImage sd_setImageWithURL:[NSURL URLWithString:[self.scrollArr[0] photo]]placeholderImage:[UIImage imageNamed:@"10.jpeg"]];
        self.lastImage.userInteractionEnabled = YES;
        [self.upScroll addSubview:self.lastImage];
        

        
        
        for (NSUInteger i = 0; i < self.scrollArr.count; i++) {
            self.scrollImage = [[UIImageView alloc] init];
            self.scrollImage.frame = CGRectMake(WIDTH * (i + 1), 0, WIDTH, 350);
            
            [self.upScroll addSubview:self.scrollImage];
            [self.scrollImage sd_setImageWithURL:[NSURL URLWithString:[self.scrollArr[i] photo]]];
            
            //            NSLog(@"%@", [self.scrollArr[i] photo]);
            
        }
        self.arrImage = [NSMutableArray array];
        for (DeclineUp *up in self.arrImages) {
            [self.arrImage addObject:up];
        }


        [self.buttonFirst sd_setImageWithURL:[NSURL URLWithString:[self.arrImage[0] photo]]placeholderImage:[UIImage imageNamed:@"10.jpeg"]];
         [self.headView addSubview:self.buttonFirst];
        
        [self.buttonSecond sd_setImageWithURL:[NSURL URLWithString:[self.arrImage[1] photo]]placeholderImage:[UIImage imageNamed:@"10.jpeg"]];
        [self.headView addSubview:self.buttonSecond];
        
        [self.buttonThird sd_setImageWithURL:[NSURL URLWithString:[self.arrImage[2] photo]]placeholderImage:[UIImage imageNamed:@"10.jpeg"]];
        [self.headView addSubview:self.buttonThird];
//        [self.upScroll reloadInputViews];
        [self.tableView reloadData];

    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        
    }];
    
    
   
    AFHTTPRequestOperationManager *managertable = [AFHTTPRequestOperationManager manager];
    [managertable GET:@"http://open.qyer.com/qyer/recommands/trip?client_id=qyer_ios&client_secret=cd254439208ab658ddf9&count=10&lat=38.88264691662092&lon=121.5393252398706&page=1&track_app_channel=App%2520Store&track_app_version=6.7&track_device_info=iPhone7%2C1&track_deviceid=CD8DD9AA-C227-45CD-A07E-DA485B537E39&track_os=ios%25208.4.1&type=index&v=1" parameters:nil success:^(AFHTTPRequestOperation *operation, id responseObject) {
        NSDictionary *dic = responseObject;
        NSArray *arr = [DeclineUp baseModelArr:dic[@"data"]];
        NSString *sandBoxPath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject];
        NSString *docPath = [sandBoxPath stringByAppendingPathComponent:@"zgsatable.plist"];
        //归档
        [NSKeyedArchiver archiveRootObject:arr toFile:docPath];
        
//        NSArray *tempa = [NSKeyedUnarchiver unarchiveObjectWithFile:docPath];

       
        self.downArr = [NSMutableArray array];
        for (DeclineUp *down in arr) {
            [self.downArr addObject:down];
            
        }
        NSLog(@"%@", self.downArr);
        [self.tableView reloadData];
        self.HUD.hidden = YES;
        [self.tableView.header endRefreshing];
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        
        
    }];

}


- (void)searchbarAction:(UINavigationItem *)item{
    
    ZGSSearchViewController *searchVC = [[ZGSSearchViewController alloc] init];
    searchVC.hidesBottomBarWhenPushed = YES;
    [self.navigationController pushViewController:searchVC animated:YES];
}

- (void)header{
    //把已经刷新的数据删除,否则越刷新重复数据越多
//    [self.mArr removeAllObjects];
    [self creatData];
}

-(void)footer{
    static NSInteger i = 1;
    i++;
//        NSLog(@"%ld",self.page);
    
    NSString *StrTwo = [NSString stringWithFormat:@"http://open.qyer.com/qyer/recommands/trip?client_id=qyer_ios&client_secret=cd254439208ab658ddf9&count=10&lat=38.88264691662092&lon=121.5393252398706&page=%ld&track_app_channel=App%%2520Store&track_app_version=6.7&track_device_info=iPhone7%%2C1&track_deviceid=CD8DD9AA-C227-45CD-A07E-DA485B537E39&track_os=ios%%25208.4.1&type=index&v=1", (long)i];
    AFHTTPRequestOperationManager *managertable = [AFHTTPRequestOperationManager manager];
    [managertable GET:StrTwo parameters:nil success:^(AFHTTPRequestOperation *operation, id responseObject) {
        NSDictionary *dic = responseObject;
        NSArray *arr = [DeclineUp baseModelArr:dic[@"data"]];
//        self.downArr = [NSMutableArray array];
        for (DeclineUp *down in arr) {
            [self.downArr addObject:down];
            
        }
//        NSLog(@"%@", self.downArr);
//        [self.downArr removeLastObject];
        [self.tableView reloadData];
        [self.tableView.footer endRefreshing];
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        
        NSString *sandBoxPatha = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject];
        NSString *docPatha = [sandBoxPatha stringByAppendingPathComponent:@"zgstable.plist"];
        NSArray *tempa = [NSKeyedUnarchiver unarchiveObjectWithFile:docPatha];
        NSLog(@"%@!!!!!!!!!!!", tempa);
        self.downArr = [NSMutableArray array];
        for (DeclineUp *down in tempa) {
            [self.downArr addObject:down];
            
        }
        [self.tableView reloadData];
    }];
    
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return self.downArr.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    ZGSDownTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"reusetable" forIndexPath:indexPath];
    [cell.leftImage sd_setImageWithURL:[NSURL URLWithString:[self.downArr[indexPath.row] photo]]placeholderImage:[UIImage imageNamed:@"10.jpeg"]];
    NSString *str = [NSString stringWithFormat:@"%@人浏览", [self.downArr[indexPath.row] views]];
    cell.labelViews.text = str;
    NSString *strReplys = [NSString stringWithFormat:@"%@评论", [self.downArr[indexPath.row] replys]];
    cell.labelUsername.text = [self.downArr[indexPath.row] username];
    cell.labelReplys.text = strReplys;
    cell.labelTitle.text = [self.downArr[indexPath.row] title];

    return cell;
}


- (void)moreSpecialAction:(UIButton *)button{
    ZGSmoreSpecialViewController *moreSpecialVC = [[ZGSmoreSpecialViewController alloc] init];
    //[self.navigationController pushViewController:moreSpecialVC animated:YES];
   [self presentViewController:moreSpecialVC animated:YES completion:^{
       
       
   }];
    
}

- (void)tapAction:(UITapGestureRecognizer *)tap{
    NSLog(@"我被点击了");
    ScrollWebViewController *web = [[ScrollWebViewController alloc] init];
    DeclineUp *up = [[DeclineUp alloc] init];
    for (NSUInteger i = 1; i <= self.scrollArr.count; i++) {
        if (self.upScroll.contentOffset.x == i * WIDTH) {
            up = self.scrollArr[i - 1];
            web.urlStr = up.url;
            [self presentViewController:web animated:YES completion:^{
                
                
            }];
        }
        
    }
    
}

//- (void)tapSecondAction

- (void)tapFirstAction:(UITapGestureRecognizer *)tap{
      NSLog(@"我被点击了");
    ScrollWebViewController *web = [[ScrollWebViewController alloc] init];
    DeclineUp *up = [[DeclineUp alloc] init];
    up = self.arrImage[0];
    web.urlStr = up.url;
    [self presentViewController:web animated:YES completion:^{
        
        
    }];
}

- (void)tapSecondAction:(UITapGestureRecognizer *)tap{
      NSLog(@"我被点击了");
    ScrollWebViewController *web = [[ScrollWebViewController alloc] init];
    DeclineUp *up = [[DeclineUp alloc] init];
    up = self.arrImage[1];
    web.urlStr = up.url;
    [self presentViewController:web animated:YES completion:^{
        
        
    }];


}

- (void)tapThirdAction:(UITapGestureRecognizer *)tap{
      NSLog(@"我被点击了");
    ScrollWebViewController *web = [[ScrollWebViewController alloc] init];
    DeclineUp *up = [[DeclineUp alloc] init];
    up = self.arrImage[2];
    web.urlStr = up.url;
    [self presentViewController:web animated:YES completion:^{
        
        
    }];
}


- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView{
    if (self.upScroll.contentOffset.x == (self.scrollArr.count + 1) * WIDTH) {
        self.upScroll.contentOffset = CGPointMake(WIDTH, 0);
    }else if (self.upScroll.contentOffset.x == 0){
        self.upScroll.contentOffset = CGPointMake(self.scrollArr.count * WIDTH, 0);
    }
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    ScrollWebViewController *web = [[ScrollWebViewController alloc] init];
    DeclineUp *down = [[DeclineUp alloc] init];
    down = self.downArr[indexPath.row];
    web.urlStr = down.view_url;
    NSLog(@"%@", web.urlStr);
    [self presentViewController:web animated:YES completion:^{
        
        
    }];
    
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
